import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName MapDemo01
 * @Description Map 接口的方法演示
 * @Author Li
 * @Date 2022/8/6 9:03
 * @ModifyDate 2022/8/6 9:03
 * @Version 1.0
 */
public class MapDemo01 {
    public static void main(String[] args) {
        // 创建Map对象
        Map<String, String> map = new HashMap<>();

        // public V put(K key, V value)：把指定的键与指定的值添加到Map集合中
        map.put("14122471", "张三");
        map.put("14122472", "李四");
        map.put("14122473", "王二");
        map.put("14122474", "麻子");
        System.out.println(map);
        System.out.println("============================================================");

        // public V remove(Object key)：把指定的键所对应的键值对元素在Map集合中删除，返回被删除的值
        String removeKey = map.remove("14122473");
        System.out.println("removeKey-14122473:" + removeKey);
        System.out.println(map);
        System.out.println("============================================================");

        // public V get(Object key)：根据指定的键，在Map集合中获取对应的值
        String getKey = map.get("14122472");
        System.out.println("getKey-14122472:" + getKey);
        System.out.println("============================================================");

        // public boolean containsKey(Object key) ：如果此映射包含该指定键的映射关系，则返回true
        boolean containsKey = map.containsKey("14122471");
        System.out.println("containsKey-14122471:" + containsKey);
    }
}
